/**
  ******************************************************************************
  * @file     DCMotor_PWM6612_Driver.h
  * @author		HpDadi 
  * @version  V1.0
  * @date     18-June-2018
  * @brief    This is a Driver based on the chip 6612, a double H bridge PWM DCmotor Driver.    
  ******************************************************************************
  * @attention
  * 1, Define DCMotor_PWM6612_UseA or DCMotor_PWM6612_BseB when A's or B's H bridge is used
  *	2, Set your pins configuration. @ref Pins_Define
  ******************************************************************************
  */
 
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DCMotor_PWM6612_Driver_h
#define DCMotor_PWM6612_Driver_h
 
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"

/** @defgroup DCMotor_PWM6612_Driver
  * @{
  */

/** @defgroup Driver_Exported_Constants
  * @{
  */
  
/** @defgroup Pins_Define
  * @{
  */

/* Please, set your own pins configuratons */
#define DCMotor_PWM6612_STBY_Port		GPIOA
#define DCMotor_PWM6612_STBY_Pin		GPIO_Pin_0
#define DCMotor_PWM6612_STBY_Clock  RCC_APB2Periph_GPIOA    

#ifdef DCMotor_PWM6612_UseA

#define DCMotor_PWM6612_AIN1_Port		GPIOA
#define DCMotor_PWM6612_AIN1_Pin		GPIO_Pin_1
#define DCMotor_PWM6612_AIN1_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_AIN2_Port		GPIOA
#define DCMotor_PWM6612_AIN2_Pin		GPIO_Pin_2
#define DCMotor_PWM6612_AIN2_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_PWMA_TIM      TIM1							/*!< Specifies the Tim of PWMA.
																												 This parameter can be a value of TIM1, TIM2, TIM3, TIM4*/
#define DCMotor_PWM6612_PWMA_Clock		RCC_APB2Periph_TIM1 																												 
#define DCMotor_PWM6612_PWMA_CH		    0x01							/*!< Specifies the Tim_channel of PWMA.
																												 This parameter can be a value of 0x01 for CH1, 0x02 for CH2 so as 0x03 and 0x04*/
#define DCMotor_PWM6612_PWMA_CH_Port	GPIOA
#define DCMotor_PWM6612_PWMA_CH_Pin		GPIO_Pin_8
#define DCMotor_PWM6612_PWMA_CH_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_PortA_InitVoltage	((uint16_t) 50)		/*!<Spectify the initial Voltage of DCmotor  
																													@note the range is between 0 to 100, no Voltage to full Voltage */

#endif 

#ifdef DCMotor_PWM6612_UseB

#define DCMotor_PWM6612_BIN1_Port		GPIOA
#define DCMotor_PWM6612_BIN1_Pin		GPIO_Pin_1
#define DCMotor_PWM6612_BIN1_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_BIN2_Port		GPIOA
#define DCMotor_PWM6612_BIN2_Pin		GPIO_Pin_2
#define DCMotor_PWM6612_BIN2_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_PWMB_TIM      TIM1							/*!< Specifies the Tim of PWMA.
																														 This parameter can be a value of TIM1, TIM2, TIM3, TIM4*/
#define DCMotor_PWM6612_PWMB_Clock		RCC_APB2Periph_TIM1 																												 
#define DCMotor_PWM6612_PWMB_CH		    0x01							/*!< Specifies the Tim_channel of PWMA.
																														 This parameter can be a value of 0x01 for CH1, 0x02 for CH2 so as 0x03 and 0x04*/
#define DCMotor_PWM6612_PWMB_CH_Port	GPIOA
#define DCMotor_PWM6612_PWMB_CH_Pin		GPIO_Pin_8
#define DCMotor_PWM6612_PWMB_CH_Clock	RCC_APB2Periph_GPIOA 

#define DCMotor_PWM6612_PortB_InitVoltage	((uint16_t) 50)		/*!<Spectify the initial Voltage of DCmotor  
																																@note the range is between 0 to 100, no Voltage to full Voltage */

#endif

/**
  * @}
  */

/** @defgroup Driver_Port
  * @{
  */

#define DCMotor_PWM6612_PortA		((uint8_t) 0x00)
#define DCMotor_PWM6612_PortB        ((uint8_t) 0x01)

#define IS_GET_DCMotor_PWM6612_Port(Port)	(((Port)==DCMotor_PWM6612_PortA) || \
											 ((Port)==DCMotor_PWM6612_PortB))
	
/**
  * @}
  */

/**
  * @}
  */
	 

/** @defgroup Driver_Exported_Functions
  * @{
  */

void DCMotor_PWM6612_Init(uint8_t DCMotor_PWM6612_Port, uint16_t PWM_Period,uint16_t DCMotor_PWM6612_Port_InitVoltage);
void DCMotor_PWM6612_Enable(void);
void DCMotor_PWM6612_Pause(uint8_t DCMotor_PWM6612_Port);
void DCMotor_PWM6612_Forward(uint8_t DCMotor_PWM6612_Port);
void DCMotor_PWM6612_Reverse(uint8_t DCMotor_PWM6612_Port);
void DCMotor_PWM6612_SetVoltage(uint8_t DCMotor_PWM6612_Port, uint16_t Voltage);
void DCMotor_PWM6612_SetPWMPeriod(uint8_t DCMotor_PWM6612_Port,uint16_t PWM_Peroid);

/**
  * @}
  */

/**
  * @}
  */


 
#endif
